package io.github.yedaxia.apidocs.parser;

import com.alibaba.fastjson.JSONObject;
import io.github.yedaxia.apidocs.Utils;
import lombok.Data;

/**
 * response node
 *
 * @author yeguozhong yedaxia.github.com
 */
@Data
public class ResponseNode extends ClassNode {

    private RequestNode requestNode;

    private String stringResult;

    @Override
    public String toJsonApi() {
        if(stringResult != null){
            try{
                return Utils.toPrettyJson((JSONObject.parse(stringResult)));
            }catch (Exception ex){
                // do nothing
                return stringResult;
            }
        }
        return super.toJsonApi();
    }
}
